﻿<phone:PhoneApplicationPage 
    x:Class="Omnia.Wallet.Views.CaseDetailsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:viewmodel="clr-namespace:Omnia.ViewModels;assembly=Omnia.ViewModels"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:ec="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" 
    xmlns:es="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing" 
    xmlns:UX="clr-namespace:Omnia.UX;assembly=Omnia.UX"
    xmlns:Converters="clr-namespace:Omnia.Converters;assembly=Omnia.Converters"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:ResourceKeyToPathdataConverter x:Key="ResourceKeyToPathdataConverter" />
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </phone:PhoneApplicationPage.Resources>
    
    
    <Grid x:Name="LayoutRoot">
    	<Grid.Background>
    		<ImageBrush Stretch="{Binding GlobalSettings.BackgroundImageStretch}" ImageSource="{Binding BackgroundImageSource, Mode=OneWay}"/>
    	</Grid.Background>
        <Grid.DataContext>
            <viewmodel:CaseDetailsViewModel/>
        </Grid.DataContext>
        
        <controls:Pivot Title="{StaticResource IDS_PAGE_TITLE}">
            
            <controls:PivotItem Header="{StaticResource IDS_ITEM_HEADER_CASE}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>
                    <ScrollViewer>
                        <StackPanel>
                            <TextBlock Text="{StaticResource IDS_LABEL_CASE_TITLE}" 
                                       Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBox Text="{Binding CurrentEditCaseItem.Title, Mode=TwoWay}"/>
                            <TextBlock Text="{StaticResource IDS_LABEL_CASE_PLACE}" 
                                       Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBox Text="{Binding CurrentEditCaseItem.Place, Mode=TwoWay}"/>
                            <toolkit:DatePicker Header="{StaticResource IDS_LABEL_CASE_STARTDATE}" 
                                                Value="{Binding CurrentEditCaseItem.StartDate, Mode=TwoWay}"/>
                            <TextBlock Text="{StaticResource IDS_LABEL_CASE_DESCRIPTION}" 
                                       Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBox AcceptsReturn="True" 
                                     Text="{Binding CurrentEditCaseItem.Description, Mode=TwoWay}"/>
                            <TextBlock Text="{StaticResource IDS_LABEL_CASE_ADDUP}" 
                                       Style="{StaticResource PhoneTextSubtleStyle}" />
                            <Grid Margin="12">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="1"/>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="1"/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>

                                <Grid  Background="{StaticResource PhoneSubtleBrush}">
                                    <StackPanel HorizontalAlignment="Center">
                                        <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                   Foreground="{StaticResource PhoneBackgroundBrush}" 
                                                   Text="{Binding CurrentEditCaseItem.SumOfIncome}" 
                                                   HorizontalAlignment="Center"/>
                                        <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                   Text="{StaticResource IDS_LABEL_CASE_INCOME}" 
                                                   HorizontalAlignment="Center" 
                                                   Foreground="{StaticResource PhoneChromeBrush}"/>
                                    </StackPanel>
                                </Grid>

                                <Grid  Background="{StaticResource PhoneSubtleBrush}" Grid.Column="2">
                                    <StackPanel HorizontalAlignment="Center">
                                        <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                   Foreground="{StaticResource PhoneBackgroundBrush}" 
                                                   Text="{Binding CurrentEditCaseItem.SumOfExpense}" 
                                                   HorizontalAlignment="Center"/>
                                        <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                   Text="{StaticResource IDS_LABEL_CASE_EXPENSE}" 
                                                   HorizontalAlignment="Center" 
                                                   Foreground="{StaticResource PhoneChromeBrush}"/>
                                    </StackPanel>
                                </Grid>
                                <Grid  Background="{StaticResource PhoneSubtleBrush}" Grid.Column="4">
                                    <StackPanel HorizontalAlignment="Center">
                                        <TextBlock Style="{StaticResource PhoneTextTitle3Style}" 
                                                   Foreground="{StaticResource PhoneBackgroundBrush}" 
                                                   Text="{Binding CurrentEditCaseItem.TransactionCount}" 
                                                   HorizontalAlignment="Center"/>
                                        <TextBlock Style="{StaticResource PhoneTextSmallStyle}" 
                                                   Text="{StaticResource IDS_LABEL_CASE_COUNT}" 
                                                   HorizontalAlignment="Center" 
                                                   Foreground="{StaticResource PhoneChromeBrush}"/>
                                    </StackPanel>
                                </Grid>
                            </Grid>
                        </StackPanel>
                    </ScrollViewer>

                    <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right">
                        <UX:UXPathButton Command="{Binding UpdateCaseCommand}" 
                                         IconPath="{StaticResource PATH_ICON_SUBMIT}"
                                         Padding="10"
                                         Margin="12"/>
                        
                        <UX:UXPathButton Command="{Binding DeleteCaseCommand}"
                                         IconPath="{StaticResource PATH_ICON_DELETE}"
                                         Margin="12"/>
                        
                        <UX:UXPathButton Margin="12" Uri="/Views/CasesView.xaml"
                                         IconPath="{StaticResource PATH_ICON_PREVIOUS}"
                                         Padding="11"/>
                    </StackPanel>
                </Grid>
            </controls:PivotItem>

            <!--枢轴项二-->
            <controls:PivotItem Header="{StaticResource IDS_ITEM_HEADER_TRANSACTION}">
                <Grid>
                    <ListBox ItemsSource="{Binding LinkedTransactionCollection}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Grid>
                                                <VisualStateManager.CustomVisualStateManager>
                                                    <ec:ExtendedVisualStateManager/>
                                                </VisualStateManager.CustomVisualStateManager>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="auto"/>
                                                    <ColumnDefinition />
                                                    <ColumnDefinition Width="auto"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition Height="auto"/>
                                                </Grid.RowDefinitions>
                                                <Path Data="{Binding Category.IconResourceKey, Converter={StaticResource ResourceKeyToPathdataConverter}}" 
                                                              Stretch="Uniform" 
                                                              Fill="{StaticResource PhoneForegroundBrush}" 
                                                              Width="20" Height="20" Margin="12" 
                                                              RenderTransformOrigin="0.5,0.5">
                                                    <Path.RenderTransform>
                                                        <TransformGroup>
                                                            <RotateTransform Angle="0" />
                                                            <ScaleTransform ScaleX="1" ScaleY="1" />
                                                        </TransformGroup>
                                                    </Path.RenderTransform>
                                                </Path>
                                                <TextBlock Text="{Binding Category.Name}" 
                                                                   Style="{StaticResource PhoneTextNormalStyle}" 
                                                                   Grid.Column="1" VerticalAlignment="Center" />
                                                <TextBlock Text="{Binding Amount, StringFormat=\{0:c\}}" 
                                                                   Style="{StaticResource PhoneTextLargeStyle}" 
                                                                   Grid.Column="2" VerticalAlignment="Center" 
                                                                   Foreground="{StaticResource PhoneAccentBrush}"/>

                                                <Grid x:Name="grid" Grid.Row="1" Margin="12,0" 
                                                              Grid.ColumnSpan="3" 
                                                              Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsSelected, Converter={StaticResource BooleanToVisibilityConverter}}">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition Height="auto"/>
                                                        <RowDefinition Height="auto"/>
                                                    </Grid.RowDefinitions>
                                                    <es:RegularPolygon Fill="{StaticResource PhoneSubtleBrush}" HorizontalAlignment="Right" 
                                                                               InnerRadius="1" 
                                                                               PointCount="3" 
                                                                               Stretch="Fill" 
                                                                               UseLayoutRounding="False" 
                                                                               Width="20" Height="16" Margin="0,0,20,0" 
                                                                               StrokeThickness="0"/>
                                                    <StackPanel Grid.Row="1" Background="{StaticResource PhoneSubtleBrush}">
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition/>
                                                                <ColumnDefinition Width="auto"/>
                                                            </Grid.ColumnDefinitions>
                                                            <TextBlock Text="{Binding Paymentway, Converter={StaticResource EnumTranslateConverter}}" 
                                                                               Style="{StaticResource PhoneTextNormalStyle}" 
                                                                               Foreground="{StaticResource PhoneChromeBrush}" />
                                                            <TextBlock Text="{Binding Time, StringFormat=HH:mm}" 
                                                                               Grid.Column="1" 
                                                                               Style="{StaticResource PhoneTextNormalStyle}" 
                                                                               Foreground="{StaticResource PhoneChromeBrush}" />
                                                        </Grid>
                                                        <TextBlock Style="{StaticResource PhoneTextNormalStyle}" 
                                                                   TextWrapping="Wrap" 
                                                                   Foreground="{StaticResource PhoneChromeBrush}">
                                                            <Run Text="{StaticResource IDS_LABEL_TRANS_REMARK}"/>
                                                            <Run Text="： "/>
                                                            <Run Text="{Binding Remark}"/>
                                                        </TextBlock>
                                                        <TextBlock Style="{StaticResource PhoneTextNormalStyle}" 
                                                                   TextWrapping="Wrap" 
                                                                   Foreground="{StaticResource PhoneChromeBrush}">
                                                            <Run Text="{StaticResource IDS_LABEL_TRANS_LINK}"/>
                                                            <Run Text="： "/>
                                                            <Run Text="{Binding Case.Title}"/>
                                                        </TextBlock>
                                                    </StackPanel>
                                                </Grid>
                                            </Grid>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </Grid>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>
    
</phone:PhoneApplicationPage>